<%--
  Created by IntelliJ IDEA.
  User: ZYJY
  Date: 2020-08-11
  Time: 15:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <base href="${pageContext.request.contextPath}/">
    <%--<script src="jquery-3.2.1/jquery-3.2.1.min.js"></script>--%>
    <%--<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>--%>
   <%-- <script src="jquery-3.3.1/jquery-3.3.1.min.js"></script>--%>
    <script src="js/jquery-3.3.1.min.js" type="text/javascript"></script>
    <script>
        //js的字面量对象
        var emp = {
            "empno": 101,
            "ename": 'tom'
           /* "job": 'staff',
            "sal": 4500,
            "hiredate": '2020/01/09'*/
        };

        // emp = JSON.stringify(emp);
        //发送异步请求
       /* $.ajax('${pageContext.request.contextPath}/hello/addEmp.action', {
            type: 'get',
            data: emp,
            //内容类型：将数据转换为keyValue向服务器提交
            contentType: 'application/x-www-form-urlencoded',
            success: function(resp) {
                alert(resp);
            }
        });*/

       /* $.ajax('${pageContext.request.contextPath}/hello/addEmp4.action', {
            type: 'post',
            data: JSON.stringify(emp),
            //内容类型：发送json数据
           contentType: 'application/json',
            success: function(resp) {
                console.log(resp)
            }
        })
*/

        $.ajax('${pageContext.request.contextPath}/hello/getEmp.action', {
            type: 'get',
            dataType:"json",
            //内容类型：发送json数据
            contentType: 'application/json',
            success: function(data) {
                console.log(data.ename)
            }
        })







    </script>
    <title>Title</title>
</head>
<body>
    <h1>index</h1>
</body>
</html>